package edu.sctu.zcy.month201506.day20150628test;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * Created by user24 on 2015/6/28.
 */
public class GetGoodsCount {

    public void getCount(File file){

        int count1 = 0;
        int count2 = 0;

        try {
            ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));

            JsonData jsonData = (JsonData) objectInputStream.readObject();

            for (int i = 0; i < jsonData.list.size(); i++) {
                if(Float.parseFloat(jsonData.list.get(i).goods_price) > 100){
                    count1++;
                }else {
                    count2++;
                }
            }
            System.out.println("商品价格大于100有："+count1);
            System.out.println("商品价格小于100有："+count2);

        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
